<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Vue 数字时钟</title>
    <style type="text/css">
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            background-color: #f0f0f0;
            margin: 0;
            padding: 0;
        }

        #app {
            margin-top: 20%;
        }

        .time {
            font-size: 5em;
            margin: 0.1em;
            font-weight: lighter;
        }

        .date {
            font-size: 1.5em;
            margin: 0.1em;
            font-weight: lighter;
        }

        .title {
            font-size: 1.5em;
            margin: 0.1em;
            font-weight: lighter;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="date">{{ currentDate }}</div>
        <div class="time">{{ currentTime }}</div>
        <div class="title">Vue 数字时钟</div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                currentDate: '',
                currentTime: ''
            },
            created() {
                this.updateTime();
                setInterval(this.updateTime, 1000);
            },
            methods: {
                updateTime() {
                    const now = new Date();
                    this.currentDate = `${now.getFullYear()}-${this.zeroPadding(now.getMonth() + 1)}-${this.zeroPadding(now.getDate())} ${this.getDayName(now.getDay())}`;
                    this.currentTime = `${this.zeroPadding(now.getHours())}:${this.zeroPadding(now.getMinutes())}:${this.zeroPadding(now.getSeconds())}`;
                },
                zeroPadding(num) {
                    return num < 10 ? '0' + num : num;
                },
                getDayName(x) {
                    const days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
                    return days[x];
                }
            }
        });
    </script>
</body>

</html>